/**
 * 
 */
package com.bolbachchan.common.ui;

/**
 * @author Chaitanya
 * 
 */
public class DefaultColumn implements Column {

    private String columnName;
    private ColumnType columnType;
    private String columnFieldNameForRow;

    /**
     * 
     */
    public DefaultColumn() {

    }

    /**
     * @param columnName
     * @param columnFieldNameForRow
     */
    public DefaultColumn(String columnName, String columnFieldNameForRow) {
	this.columnName = columnName;
	this.columnFieldNameForRow = columnFieldNameForRow;
    }

    /**
     * @param columnName
     * @param columnType
     * @param columnFieldNameForRow
     */
    public DefaultColumn(String columnName, ColumnType columnType, String columnFieldNameForRow) {
	this.columnName = columnName;
	this.columnType = columnType;
	this.columnFieldNameForRow = columnFieldNameForRow;
    }

    /*
     * (non-Javadoc)
     * @see com.bolbachchan.common.ui.Column#getColumnName()
     */
    @Override
    public String getColumnName() {
	return columnName;
    }

    /**
     * @param columnName
     */
    public void setColumnName(String columnName) {
	this.columnName = columnName;
    }

    /*
     * (non-Javadoc)
     * @see com.bolbachchan.common.ui.Column#getColumnType()
     */
    @Override
    public ColumnType getColumnType() {
	return columnType;
    }

    /**
     * @param columnType
     */
    public void setColumnType(ColumnType columnType) {
	this.columnType = columnType;
    }

    /*
     * (non-Javadoc)
     * @see com.bolbachchan.common.ui.Column#getColumnFieldNameForRow()
     */
    @Override
    public String getColumnFieldNameForRow() {
	return columnFieldNameForRow;
    }

    /**
     * @param columnFieldNameForRow
     */
    public void setColumnFieldNameForRow(String columnFieldNameForRow) {
	this.columnFieldNameForRow = columnFieldNameForRow;
    }

    /*
     * (non-Javadoc)
     * @see java.lang.Object#toString()
     */
    @Override
    public String toString() {
	StringBuilder builder = new StringBuilder();
	builder.append("DefaultColumn [columnName=");
	builder.append(columnName);
	builder.append(", columnType=");
	builder.append(columnType);
	builder.append(", columnFieldNameForRow=");
	builder.append(columnFieldNameForRow);
	builder.append("]");
	return builder.toString();
    }

    /*
     * (non-Javadoc)
     * @see java.lang.Object#hashCode()
     */
    @Override
    public int hashCode() {
	final int prime = 31;
	int result = 1;
	result = prime * result + ((columnFieldNameForRow == null) ? 0 : columnFieldNameForRow.hashCode());
	result = prime * result + ((columnName == null) ? 0 : columnName.hashCode());
	result = prime * result + ((columnType == null) ? 0 : columnType.hashCode());
	return result;
    }

    /*
     * (non-Javadoc)
     * @see java.lang.Object#equals(java.lang.Object)
     */
    @Override
    public boolean equals(Object obj) {
	if (this == obj)
	    return true;
	if (obj == null)
	    return false;
	if (getClass() != obj.getClass())
	    return false;
	DefaultColumn other = (DefaultColumn) obj;
	if (columnFieldNameForRow == null) {
	    if (other.columnFieldNameForRow != null)
		return false;
	}
	else if (!columnFieldNameForRow.equals(other.columnFieldNameForRow))
	    return false;
	if (columnName == null) {
	    if (other.columnName != null)
		return false;
	}
	else if (!columnName.equals(other.columnName))
	    return false;
	if (columnType != other.columnType)
	    return false;
	return true;
    }
}
